Skip to main content

All Questions

0votes
1answer
374views

Grid Dynamic Programming

atcoder.jp Problem Statement: There is a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the ...
Eren Yeager's user avatar
2votes
1answer
81views

Why below recursive DP solution is so slow? (Leetcode Q# 123 - Best Time to Buy and Sell Stock III)

This is regarding leetcode Question# 123. I have solved the question (code below) but the solution is showing "Your runtime beats 5.89 % of cpp submissions."? Is there any additional ...
Rajdeep Paul's user avatar
1vote
1answer
1kviews

Odd Even Subarrays

I've been trying to understand Dynamic Programming lately, here's the question I just attempted: You are given an array A of N positive integer values. A subarray of this array is called an Odd-Even ...
Pranjal Verma's user avatar
7votes
6answers
2kviews

Yet another Fibonacci number generator

First attempt at dynamic programming. I want to make this run faster and better. fibonacci.cpp ...
anna328p's user avatar
6votes
1answer
731views

Multiple 0-1 knapsack

I have a problem were the time in minutes of N songs are given and I have to write the maximum number of time in K CDs. Input description The first input line consists of two positive integers N e K (...
Felipe's user avatar
3votes
1answer
2kviews

Calculate possible balances in piggy-bank by weight

I have solved Piggy-Bank problem on SPOJ using dynamic programming. The question asks you to get the minimum value that is possible with given weight (\$w\$) and one or more coins (\$n\$) with given ...
Hasil Sharma's user avatar
11votes
3answers
2kviews

Substitution cipher algorithm performance boost

This algorithm is meant to read a string of numbers on an input, a naive substitution cipher code (A = 1, B = 2, ..., Z = 26) and output the number of ways the code could be interpreted (e.g. 25114 ...
mirgee's user avatar
5votes
2answers
5kviews

Optimizing O(m n) solution for longest common subsequence challenge

Given two strings string X of length x1 and string Y of length ...
swapedoc's user avatar

close